package com.neuedu.advance.control.c1;

/**
 * @author 金山
 * 项目：javase
 * site: https://blog.fulfill.com.cn
 * 描述
 * @data 2024/10/1712:00
 */
public class Person {

   private String name;
    private  int age;


    //添加一个public 方法 用于  操作 属性
    public void setName(String name){
        name = name.trim();
        this.name = name;
    }


    public void setAge(int age){
        if(age<0){
            System.err.println("年龄异常....");
        }
        this.age = age;
    }

    public String getName(){
        return  this.name;
    }


    public int getAge() {
        return age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
